package com.javaEE.gamepigeon.entity;


import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;

@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel("User对象")
public class User implements UserDetails {

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("用户姓名")
    private String username;

    @ApiModelProperty("用户学校ID")
    private Integer schoolId;

    @ApiModelProperty("用户微信openid")
    private String openId;

    @ApiModelProperty("用户专业id")
    private Integer departmentId;

    @ApiModelProperty("用户头像")
    private String avatarUrl;

    @ApiModelProperty("用户签名")
    private String userSign;

    @ApiModelProperty("用户学校")
    private School school;

    @ApiModelProperty("用户专业")
    private Department department;

    @ApiModelProperty("用户密码/仅作为web端登录用")
    private String password;

    @ApiModelProperty("用户权限")
    private ArrayList<SimpleGrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
